<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <div id="app"></div>

  <template id="my-app">
    <!-- 默认传入event对象，可以在方法中获取 -->
    <button @click="btnClick1">按钮1</button>
    <!-- $event可以获取到事件发生时的事件对象 -->
    <button @click="btnClick2($event,'coderwhy')">按钮2</button>
  </template>

  <script src="../js/vue.js"></script>
  <script>
    const App = {
      template: "#my-app",
      data() {
        return {
          message: "Hello World",
        }
      },
      methods: {
        btnClick1(event) {
          console.log(event);
        },
        btnClick2(event, name) {
          console.log(name, event);
        }
      }
    };

    Vue.createApp(App).mount("#app");
  </script>
</body>

</html>